package com.microservice.skeleton.auth.controller;

import java.util.Map;

import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.github.pagehelper.PageInfo;
import com.microservice.skeleton.auth.po.People;
import com.microservice.skeleton.auth.service.PeopleService;

@Controller
public class FtlController {
	@Autowired
	private PeopleService peopleService;
	
/*	@Value("${server.servlet.context-path}")
	private String xiangmuming ;
	*/
	
	@RequestMapping("/ftlindex")
	private String ftlindex( Map<String, Object> map,@Param("pageNum") int pageNum , @Param("pageSize") int pageSize ) {
		// TODO Auto-generated method stub
		
		if(pageNum<=1) {
			pageNum=1;
		}
		
		PageInfo<People> peoplePage = peopleService.getUPeople(pageNum, pageSize);
		map.put("peopleList", peoplePage.getList());
		map.put("pageInfo", peoplePage);
		//map.put("pageNo", pageNum);
		//map.put("pageSize", pageSize);
		//map.put("toURL", "http://localhost:8888/ftlindex");
		//map.put("pageCount", pageSize);
		//map.put("method", "post");
		map.put("xiangmuming", "/");
		//map.put("recordCount", peoplePage.getSize());
		return "ftlindex";
	}
	
	@RequestMapping("/ftlerror")
	private String ftlerror( Map<String, Object> map) {
		// TODO Auto-generated method stub
		int j = 1/0;
		map.put("jjj", j);
		return "ftlerror";
	}
	
	/*@RequestMapping("/peopleUnion")
	private String peopleUnion( Map<String, Object> map,@Param("pageNum") int pageNum , @Param("pageSize") int pageSize ) {
		// TODO Auto-generated method stub
		
		if(pageNum<=1) {
			pageNum=1;
		}
		
		PageInfo<People> peoplePage = peopleService.getPeopleUnion(pageNum, pageSize);
		map.put("peopleList", peoplePage.getList());
		map.put("pageInfo", peoplePage);
		map.put("pageNo", pageNum);
		map.put("pageSize", pageSize);
		map.put("xiangmuming", xiangmuming);
		map.put("toURL", "http://localhost:8888/ftlindex");
		map.put("pageCount", pageSize);
		map.put("method", "post");
		map.put("recordCount", peoplePage.getSize());
		return "peopleUnion";
	}
	   @RequestMapping("/login")
	   // @ResponseBody
	    public Object foo() {
	       // logger.info("打印日志----------------------");
	       System.out.println("/login执行"); 
		   return "login";
	    }
	   
	   
	   @RequestMapping("/peopleUnion2")
		private String peopleUnion2( Map<String, Object> map,@RequestParam(value = "pageNum", defaultValue = "1") int pageNum , @RequestParam(value = "pageSize", defaultValue = "5") int pageSize ) {
			// TODO Auto-generated method stub
			
			if(pageNum<=1) {
				pageNum=1;
			}
			
			PageInfo<People> peoplePage = peopleService.getPeopleUnion(pageNum, pageSize);
			map.put("peopleList", peoplePage.getList());
			map.put("pageInfo", peoplePage);
			map.put("pageNo", pageNum);
			map.put("pageSize", pageSize);
			map.put("xiangmuming", xiangmuming);
			map.put("toURL", "http://localhost:8888/ftlindex");
			map.put("pageCount", pageSize);
			map.put("method", "post");
			map.put("recordCount", peoplePage.getSize());
			return "peopleUnion";
		}
	   */
}
